import request from "@/utils/request";
const VITE_APP_FY_BASE_API = import.meta.env.VITE_APP_FY_BASE_API;
/**
 * 获取权益包商品
 * http://192.168.88.247:4999/web/#/105/1133
 * @param {*} data
 * @returns
 */
export function getProducts(data: any) {
  return request({
    url: "/api/v1/product/package",
    method: "post",
    data
  });
}
/**
 * 获取权益包
 * http://192.168.88.247:4999/web/#/105/1132
 * @param {*} data
 * @returns
 */
export function getPackagesList(data: any, isEncrypt?: boolean) {
  return request({
    isEncrypt: isEncrypt ?? true,
    url: "/api/v1/right_package/by_pids",
    method: "post",
    data
  });
}
/**
 * 批量领取7天权益包
 * http://192.168.88.247:4999/web/#/105/936
 * @param {*} data
 * @returns
 */
export function batchDrawTrial(data: any, noMsg: boolean) {
  return request({
    noMsg,
    url: "/api/v1/right_package/multi_draw_trial",
    method: "post",
    data
  });
}

/**
 * 获取权益包试用时长
 * http://192.168.88.247:4999/web/#/105?page_id=1965
 * @param {*} data
 * @returns
 */
export function trialPeriod(params: any, noMsg: boolean) {
  return request({
    noMsg,
    url: "/api/v1/right_package/trial_period",
    method: "get",
    params
  });
}

/**
 * 根据权益ID获取翻译剩余次数
 * http://192.168.88.247:4999/web/#/267?page_id=2461
 * @param {*} params
 * @returns
 */
export function userRightById(params: any, noMsg?: boolean) {
  return request({
    noMsg: noMsg ?? true,
    baseURL: VITE_APP_FY_BASE_API,
    url: "/translation/webs/rest_usage",
    method: "get",
    params
  });
}

/**
 * 获取加购包列表
 * http://192.168.88.247:4999/web/#/105?page_id=2118
 * @param {*} data
 * @returns
 */
export function getExtraPackage(params: any, noMsg: boolean) {
  return request({
    noMsg,
    url: "/api/v2/product/by_type",
    method: "get",
    params
  });
}

/**
 * 获取加购包权益列表
 * http://192.168.88.247:4999/web/#/283?page_id=2495
 * @param {*} data
 * @returns
 */
export function getExtraFnList(data: any, noMsg: boolean) {
  return request({
    noMsg,
    url: "/charge/api/v1/fn_list",
    method: "get",
    data
  });
}


/**
 * 迁移权益包
 * http://192.168.88.247:4999/web/#/105?page_id=3330
 * @param {*} data
 * @returns
 */
export function migratePackages(data: any, noMsg: boolean = true) {
  return request({
    noMsg,
    url: "/api/v1/migrate_pkg",
    method: "post",
    data
  });
}